<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>添加/修改页面</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="../../../component/elementUI/index.css">
    <link rel="stylesheet" href="../../../component/pear/css/pear.css"></el-input>
    <link rel="stylesheet" href="../../../style/wangeditor.css">
    <link rel="stylesheet" href="../../../style/index.css">
    <style>
        .el-input.is-disabled .el-input__inner {
            background-color: #fff;
            color: #606266;;
        }
    </style>
</head>

<body>
    <div id="app" v-cloak>
        <div class="add">
            <div class="header">
                <span>{{(action == 'Add'?'添加':type =='0'?'修改':'查看')}}生产任务管理</span>
            </div>
            <div class="main" style="padding: 0 15px;">
                <!-- 配置属性, 目前仅支持 单主表 多子表 结构 -->
                <div id="form"
                    :data-options="JSON.stringify({'tableName':'production_task','formName':'dataForm' ,'primaryKey':'Production_Task_SerialNumber'})">
                    <!-- 子表 -->
                    <div
                        :data-options="JSON.stringify({'tableName':'production_task_details','formName':'childDataForm' ,'parentTableName':'detection'})">
                    </div>
                    <div
                        :data-options="JSON.stringify({'tableName':'production_task_details_allocate','formName':'childDataForm1' ,'parentTableName':'detection'})">
                    </div>

                </div>
                <div class="table_titel">
                    <div class="titel">生产任务详情</div>
                </div>

                <el-form :model="dataForm" ref="form" :inline-message="true" style="width: 100%">
                    <el-descriptions :column="2" size="large" border>
                        <el-descriptions-item>
                            <template slot="label">
                                <div class="cell-item">生产任务编号</div>
                            </template>
                            <el-form-item prop="Production_Task_SerialNumber"
                                :rules="[{ required: true, message: '请输入生产任务编号', trigger: 'blur' }]">
                                <el-input :disabled="type=='1'" v-model.trim="dataForm.Production_Task_SerialNumber"
                                    placeholder="请输入生产任务编号"></el-input>
                            </el-form-item>
                        </el-descriptions-item>
                        <el-descriptions-item>
                            <template slot="label">
                                <div class="cell-item required">产线ID</div>
                            </template>
                            <el-form-item prop="Production_Line_SerialNumber"
                                :rules="[{ required: true, message: '请选择产线ID', trigger: 'change' }]">
                                <el-select :disabled="type=='1'" v-model.trim="dataForm.Production_Line_SerialNumber"
                                    placeholder="请选择产线ID" style="width: 100%;" clearable filterable>
                                    <el-option v-for="(item,index) in production_line" :key="index"
                                        :label="item.Production_Line_SerialNumber"
                                        :value="item.Production_Line_SerialNumber" />
                                </el-select>
                            </el-form-item>
                        </el-descriptions-item>
                        <el-descriptions-item>
                            <template slot="label">
                                <div class="cell-item required">溯源批次号</div>
                            </template>
                            <el-form-item prop="Traceability_Batch_SerialNumber"
                                :rules="[{ required: true, message: '请选择溯源批次号', trigger: 'change' }]">
                                <el-select :disabled="type=='1'" v-model.trim="dataForm.Traceability_Batch_SerialNumber"
                                    placeholder="请选择溯源批次号" style="width: 100%;" clearable filterable>
                                    <el-option v-for="(item,index) in traceability_batch" :key="index"
                                        :label="item.Traceability_Batch_SerialNumber"
                                        :value="item.Traceability_Batch_SerialNumber" />
                                </el-select>
                            </el-form-item>
                        </el-descriptions-item>

                    </el-descriptions>
                </el-form>

                <div class="table_titel">
                    <div class="titel">任务单</div>
                    <div class="operation" v-if="type=='0'"><!-- -->
                        <el-button type="primary" size="small" @click="handleAdd('childDataForm')">新增</el-button>
                        <el-button type="danger" size="small" @click="handleRemove('childDataForm')">删除</el-button>
                    </div>
                </div>
                <el-form v-if="type=='0'" :model="{childDataForm:childDataForm.filter(i=>i.Row_Status != '1')}"
                    ref="childForm" :inline-message="true" style="width: 100%">
                    <el-descriptions :column="2" size="large" border
                        v-for="(item,index) in childDataForm.filter(i=>i.Row_Status != '1')" :key="index">
                        
                        <el-descriptions-item>
                            <template slot="label">
                                <div class="cell-item">任务单号</div>
                            </template>
                            <el-form-item :prop="`childDataForm.${index}.Production_Task_Detail_SerialNumber`"
                                :rules="[{ required: true, message: '请输入任务单号', trigger: 'blur' }]">
                                <el-input v-model.trim="item.Production_Task_Detail_SerialNumber" placeholder="请输入任务单号"></el-input>
                            </el-form-item>
                        </el-descriptions-item>
                        <el-descriptions-item>
                            <template slot="label">
                                <div class="cell-item">商品编号</div>
                            </template>
                            <el-form-item :prop="`childDataForm.${index}.Article_SerialNumber`"
                                :rules="[{ required: true, message: '请输入商品编号', trigger: 'blur' }]">
                                <el-input v-model.trim="item.Article_SerialNumber" placeholder="请输入商品编号"></el-input>
                            </el-form-item>
                        </el-descriptions-item>
                        <el-descriptions-item>
                            <template slot="label">
                                <div class="cell-item">批次数量</div>
                            </template>
                            <el-form-item :prop="`childDataForm.${index}.Batch_Quantit`"
                                :rules="[{ required: true, message: '请输入批次数量', trigger: 'blur' }]">
                                <el-input v-model.trim="item.Batch_Quantit" placeholder="请输入批次数量"></el-input>
                            </el-form-item>
                        </el-descriptions-item>
                        <el-descriptions-item>
                            <template slot="label">
                                <div class="cell-item">已分配数量</div>
                            </template>
                            <el-form-item :prop="`childDataForm.${index}.Assigned_Quantity`"
                                :rules="[{ required: true, message: '请输入已分配数量', trigger: 'blur' }]">
                                <el-input v-model.trim="item.Assigned_Quantity" placeholder="请输入已分配数量"></el-input>
                            </el-form-item>
                        </el-descriptions-item>
                        <el-descriptions-item>
                            <template slot="label">
                                <div class="cell-item">未分配数量</div>
                            </template>
                            <el-form-item :prop="`childDataForm.${index}.Unassigned_Quantity`"
                                :rules="[{ required: true, message: '请输入未分配数量', trigger: 'blur' }]">
                                <el-input v-model.trim="item.Unassigned_Quantity" placeholder="请输入未分配数量"></el-input>
                            </el-form-item>
                        </el-descriptions-item>

                    </el-descriptions>
                </el-form>
                
                <div class="table_titel">
                    <div class="titel">批次分配记录</div>
                    <div class="operation">
                        <el-button type="primary" size="small" @click="handleAdd('childDataForm')">新增</el-button>
                        <el-button type="danger" size="small" @click="handleRemove('childDataForm')">删除</el-button>
                    </div>
                </div>
                <el-form :model="{childDataForm:childDataForm.filter(i=>i.Row_Status != '1')}" ref="childForm"
                    :inline-message="true" style="width: 100%">
                    <el-descriptions :column="2" size="large" border
                        v-for="(item,index) in childDataForm.filter(i=>i.Row_Status != '1')" :key="index">


                        <el-descriptions-item>
                            <template slot="label">
                                <div class="cell-item">批次分配流水号</div>
                            </template>
                            <el-form-item :prop="`childDataForm.${index}.Production_Task_Detail_Allocate_SerialNumbe`"
                                :rules="[{ required: true, message: '请输入批次分配流水号', trigger: 'blur' }]">
                                <el-input v-model.trim="item.Production_Task_Detail_Allocate_SerialNumbe" placeholder="请输入批次分配流水号"></el-input>
                            </el-form-item>
                        </el-descriptions-item>
                        <el-descriptions-item>
                            <template slot="label">
                                <div class="cell-item">任务单号</div>
                            </template>
                            <el-form-item :prop="`childDataForm.${index}.Production_Task_Detail_SerialNumber`"
                                :rules="[{ required: true, message: '请输入任务单号', trigger: 'blur' }]">
                                <el-input v-model.trim="item.Production_Task_Detail_SerialNumber" placeholder="请输入任务单号"></el-input>
                            </el-form-item>
                        </el-descriptions-item>
                        <el-descriptions-item>
                            <template slot="label">
                                <div class="cell-item">批次编号</div>
                            </template>
                            <el-form-item :prop="`childDataForm.${index}.Traceability_Batch_SerialNumber`"
                                :rules="[{ required: true, message: '请输入批次编号', trigger: 'blur' }]">
                                <el-input v-model.trim="item.Traceability_Batch_SerialNumber" placeholder="请输入批次编号"></el-input>
                            </el-form-item>
                        </el-descriptions-item>
                        <el-descriptions-item>
                            <template slot="label">
                                <div class="cell-item">分配数量</div>
                            </template>
                            <el-form-item :prop="`childDataForm.${index}.Assigned_Quantity`"
                                :rules="[{ required: true, message: '请输入分配数量', trigger: 'blur' }]">
                                <el-input v-model.trim="item.Assigned_Quantity" placeholder="请输入分配数量"></el-input>
                            </el-form-item>
                        </el-descriptions-item>

                    </el-descriptions>
                </el-form>
            </div>
            <div class="footer">
                <el-button size="medium" @click="handleBack">返回</el-button>
                <el-button size="medium" v-if="type=='0'" type="primary" plain @click="handleSubmit"
                    :loading="loading">提交</el-button>
            </div>
        </div>
    </div>
    <script type="text/javascript" src="../../../utils/wangeditor.js"></script>
    <script type="text/javascript" src="../../../utils/xlsx.full.min.js"></script>
    <script type="text/javascript" src="../../../utils/jquery.min.js"></script>
    <script type="text/javascript" src="../../../utils/jquery.cookie.js"></script>
    <script type="text/javascript" src="../../../utils/vue.min.js"></script>
    <script type="text/javascript" src="../../../utils/vuex.min.js"></script>
    <script type="text/javascript" src="../../../component/elementUI/index.js"></script>
    <script type="text/javascript" src="../../../utils/components.js"></script>
    <script type="text/javascript" src="../../../utils/compressor.js"></script>
    <script type="text/javascript" src="../../../utils/validity.js"></script>
    <script type="text/javascript" src="../../../utils/utils.js"></script>
    <script type="text/javascript" src="../../../utils/http.js"></script>
    <script type="text/javascript" src="js/add.js"></script>
</body>

</html>
